#ifndef DATABASE_MYSQL_H
#define DATABASE_MYSQL_H

#include "database.h"
#include <winsock.h>
#include <mysql-connector-c-6.0.2/include/mysql.h>

namespace Zen{

class database_mysql :
	public database
{
public:
	database_mysql(const tstring& url, int port, const tstring& user, const tstring& password, const tstring& dbname = TEXT(""), const tstring& charset = TEXT("utf8"));
	~database_mysql(void);

public:
	virtual bool open();

	virtual void close();

	virtual bool is_open();

	virtual bool get_table(const tstring& sql, table_type& table);

	virtual bool get_table(const tstring& sql, table_type& table, int& records);

	virtual bool execute(const tstring& sql);

	//virtual tstring get_error();

	virtual bool begin_transaction();

	virtual bool commit_transaction();

	virtual bool exist_table(const tstring& table);

	bool create_user(const tstring& user, const tstring& password);

	bool has_table(const tstring& dbname, const tstring& table);

private:
	virtual tstring _error_message();

private:
	MYSQL mysql_;

	tstring url_;
	int port_;
	tstring user_;
	tstring password_;
	tstring dbname_;
	tstring charset_;

	//tstring error;

};//end database_mysql

}//end database
#endif
